<template>
  <!--非移动端时显示-->
  <div v-if="ismobile == 0" style="width:100%;height:100%;display: flex;justify-content: center;">
      <div style="width:36%;min-width:480px;height:100%;overflow: hidden;">
         <router-view />
      </div>
  </div>
  <!--移动端时显示-->
  <router-view v-if="ismobile == 1" />
</template>

<script>
import {ref} from "vue";

export default {
  name: 'App',
  setup() {
    //是否移动端
    const ismobile = ref(0);
    //判断是否移动端的函数
    const isMobileFunc = () => {
      let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
      if (flag === null) {
          return 0;
      } else {
         return 1;
      }
    };
    if (isMobileFunc() === 1) {
      ismobile.value = 1;
    } else {
      ismobile.value = 0;
    }
    return {
      ismobile,
      isMobileFunc,
    };
  },
}
</script>

<style>
html,body {
  margin: 0;
  height:100%;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /*margin-top: 60px;*/
  height:100%;
}
</style>
